


// Census weights: external validity

use "~/Dropbox/Independent candidates Chile/01_data/clean_data/wave1.dta", clear
cd "~/Dropbox/Independent candidates Chile/02_analyses/figures"

set scheme plottig 

// Joint

* Interaction

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 [aw = weight_joint ], cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export all_joint.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 0 [aw = weight_joint ], cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(npop, replace)  ///
coeflabels(0.indep = "       " 1.indep = "               ", labsize(medium) labcolor(black)) title("Non-Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop1_joint.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 1 [aw = weight_joint ], cl(key) 
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop2_joint.png, replace

reg choice_clean i.indep  populism2  indep_populism2  i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2 [aw = weight_joint ], cl(key)
coefplot,   omitted baselevels keep(0.indep indep_populism2)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(inte, replace)   ///
coeflabels(0.indep = "       " indep_populism2 = "                ", labsize(medium) labcolor(black)) title("Difference", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_joint.png, replace


// Rake

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 [aw = weight_rake2 ], cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export all_rake.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 0 [aw = weight_rake2 ], cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(npop, replace)  ///
coeflabels(0.indep = "       " 1.indep = "               ", labsize(medium) labcolor(black)) title("Non-Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop1_rake.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 1 [aw = weight_rake2 ], cl(key) 
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop2_rake.png, replace

reg choice_clean i.indep  populism2  indep_populism2  i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2 [aw = weight_rake2 ], cl(key)
coefplot,   omitted baselevels keep(0.indep indep_populism2)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(inte, replace)   ///
coeflabels(0.indep = "       " indep_populism2 = "                ", labsize(medium) labcolor(black)) title("Difference", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_rake.png, replace

* Basic

* Joint

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 [aw = weight_joint ], cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) ///
xlabel(-0.25(0.1)0.25, labcolor(black))  ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) ///
coeflabels(0.indep = "Party" 1.indep = "Independent" 1.atr2 = "Lawyer" 2.atr2 = "School Teacher" 3.atr2 = "Street Vendor"  /// 
1.atr3 = "35" 2.atr3 = "45" 3.atr3 = "55" 4.atr3 = "65" 1.atr4 = "Male" 2.atr4 = "Female" ,labcolor(black))
graph export coef_plot_basic_joint.png, replace

reg choice_clean i.indep  populism2  indep_populism2  i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2 [aw = weight_joint ], cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep indep_populism2  0.atr2 1.atr2  2.atr2  3.atr2  2.atr2#1.populism2 3.atr2#1.populism2 ///
0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 2.atr3#1.populism2 3.atr3#1.populism2 4.atr3#1.populism2 0.atr4 1.atr4 2.atr4  2.atr4#1.populism2) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) ///
xlabel(-0.25(0.1)0.25, labcolor(black))  headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" ///
1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) ///
coeflabels(0.indep = "Party" 1.indep = "Independent" indep_populism2 = "Independent*Anti-Elite" 1.atr2 = "Lawyer" 2.atr2 = "School Teacher" 3.atr2 = "Street Vendor"  /// 
1.atr3 = "35" 2.atr3 = "45" 3.atr3 = "55" 4.atr3 = "65" 1.atr4 = "Male" 2.atr4 = "Female" 2.atr2#1.populism2 = "School Teacher*Anti-Elite" 3.atr2#1.populism2 = "Street Vendor*Anti-Elite" ///
2.atr3#1.populism2 = "45*Anti-Elite" 3.atr3#1.populism2 = "55*Anti-Elite" 4.atr3#1.populism2 = "65*Anti-Elite" 2.atr4#1.populism2 = "Female*Anti-Elite",labcolor(black))
graph export coef_plot_basic_int_joint.png, replace

* Rake

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 [aw = weight_rake2], cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) ///
xlabel(-0.25(0.1)0.25, labcolor(black))  ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) ///
coeflabels(0.indep = "Party" 1.indep = "Independent" 1.atr2 = "Lawyer" 2.atr2 = "School Teacher" 3.atr2 = "Street Vendor"  /// 
1.atr3 = "35" 2.atr3 = "45" 3.atr3 = "55" 4.atr3 = "65" 1.atr4 = "Male" 2.atr4 = "Female" ,labcolor(black))
graph export coef_plot_basic_rake.png, replace

reg choice_clean i.indep  populism2  indep_populism2  i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2 [aw = weight_rake2], cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep indep_populism2  0.atr2 1.atr2  2.atr2  3.atr2  2.atr2#1.populism2 3.atr2#1.populism2 ///
0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 2.atr3#1.populism2 3.atr3#1.populism2 4.atr3#1.populism2 0.atr4 1.atr4 2.atr4  2.atr4#1.populism2) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) ///
xlabel(-0.25(0.1)0.25, labcolor(black))  headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" ///
1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) ///
coeflabels(0.indep = "Party" 1.indep = "Independent" indep_populism2 = "Independent*Anti-Elite" 1.atr2 = "Lawyer" 2.atr2 = "School Teacher" 3.atr2 = "Street Vendor"  /// 
1.atr3 = "35" 2.atr3 = "45" 3.atr3 = "55" 4.atr3 = "65" 1.atr4 = "Male" 2.atr4 = "Female" 2.atr2#1.populism2 = "School Teacher*Anti-Elite" 3.atr2#1.populism2 = "Street Vendor*Anti-Elite" ///
2.atr3#1.populism2 = "45*Anti-Elite" 3.atr3#1.populism2 = "55*Anti-Elite" 4.atr3#1.populism2 = "65*Anti-Elite" 2.atr4#1.populism2 = "Female*Anti-Elite",labcolor(black))
graph export coef_plot_basic_int_rake.png, replace


